#!/bin/bash

set -ev

pushd rust.vim
#git reset --hard #this clears any modifications!

#manually undo the following applied patches:
git checkout syntax_checkers/rust/rustc.vim
git checkout doc/rust.txt
git pull

#these applied patches:
#patch -Np1 -i ../20_personal_vim.patch
#PR76 includes this: patch -Np1 -i ../40_vim_no-trans_is_better.patch
patch -Np1 -i ../PR76.patch
patch -Np1 -i ../20_personal_vim_ontop_of_PR76.patch

#ugliest shiet ever(because the above patches are too close to gen a new one, unless I merge them all, or 2 of them which I don't want to!):
sed -re 's|return SyntasticMake\(\{$|let env = \{ \x27RUST_BACKTRACE\x27: \x270\x27 \}\n    return SyntasticMake\({\n        \\ \x27env\x27: env,|' -i syntax_checkers/rust/rustc.vim
# so the above sets RUST_BACKTRACE=0 because it makes it lag, due to issue: https://github.com/rust-lang/rust/issues/29293

popd

echo "All good!"

